package net.mikoo.seals.biz.common;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import net.mikoo.seals.common.HttpUtil;

public class LocationUtility {

	public static String getGodeAddr(String gps) {
		try {
			String url = "https://restapi.amap.com/v3/place/around?offset=10&page=1&key=61e5854ac789f9c5619fdc8223fff3de&location="
					+ gps + "&output=json&radius=100000&types=080000";
			String jsonStr = HttpUtil.get(url);
			;
			JSONObject obj = JSONObject.parseObject(jsonStr);
			if (obj.getInteger("status") == 1) {
				JSONArray pois = obj.getJSONArray("pois");
				JSONObject pois1 = pois.getJSONObject(0);
				String pname = pois1.getString("pname");
				String cityname = pois1.getString("cityname");
				String adname = pois1.getString("adname");
				String address = pois1.getString("address");
				String addrinfo = pname.concat(cityname).concat(adname).concat(address);
				return addrinfo;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public static void main(String[] args) {
		String address = LocationUtility.getGodeAddr("121.4737,31.23037");
		System.out.println(address);
	}

}
